package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Dept;
import cn.wolfcode.mapper.DeptMapper;
import cn.wolfcode.mapper.EmpMapper;
import cn.wolfcode.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {
@Autowired
private DeptMapper deptMapper;
@Autowired
private EmpMapper empMapper;
    @Override
    public List<Dept> getAll() {
        return deptMapper.getAll();
    }
 @Transactional()
    public void delete(Long id) {
        deptMapper.delete(id);
        empMapper.delete(id);
    }

    @Override
    public void add(Dept dept) {
        deptMapper.add(dept);
    }

    @Override
    public void update(Dept dept) {
        deptMapper.updata(dept);
    }

    @Override
    public Dept selectOneById(Long id) {
        return deptMapper.selectOneById(id);
    }
}
